using System.Collections;
using System.Collections.Generic;
using UnityEngine.EventSystems;
using UnityEngine;
using TMPro;

public class RewardCardView : MonoBehaviour
{
    [Header("组件引用")]
    public TMP_Text nameText;
    public TMP_Text descriptionText;
    public TMP_Text energyCost;
    public SpriteRenderer imageSR;
    public GameObject wrapper;

    
    
    public string cardID { get; set; } = "";

    //卡牌数据引用
    private Card _cardData;
    private Transform _transform;

    

    private void Awake()
    {
        _transform = GetComponent<Transform>();
    }

    /// <summary>
    /// 初始化卡牌UI
    /// </summary>
    public void Initialize(Card card)
    {
        _cardData = card;
        UpdateCardDisplay();
        cardID = _cardData.id;
    }

    /// <summary>
    /// 更新卡牌显示
    /// </summary>
    public void UpdateCardDisplay()
    {
        if (_cardData == null) return;

        // 设置基础信息
        nameText.text = _cardData.name;
        descriptionText.text = _cardData.GetDescription();
        energyCost.text = _cardData.energyCost.ToString();
    }

    /// <summary>
    /// 设置选中状态
    /// </summary>
    public void SetSelected(bool selected)
    {
        if (imageSR != null)
        {
            imageSR.color = selected ? Color.yellow : Color.white;
        }
    }
}

